public class Demo6 {
    public static void main(String[] args) {
        //给当前的线程取一个名字myThread
        Thread thread = new Thread(() -> {
            while (true) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }, "myThread");

        thread.start();
    }

}
